package com.jiyang.jyandroid.test02;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import com.jiyang.jyandroid.BaseActivity;
import com.jiyang.jyandroid.other.AircraftView;

/**
 * Created by jy on 2016/12/1.
 * 控制飞机
 */

public class Two_6Activity extends BaseActivity {
    private AircraftView aircraftView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        aircraftView = new AircraftView(this);
        addContentView(aircraftView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        aircraftView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                aircraftView.set_x(motionEvent.getX());
                aircraftView.set_y(motionEvent.getY());
                aircraftView.invalidate();
                return true;
            }
        });
    }

}
